package com.ww.scm.entity.mat;



import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.ww.scm.entity.AbstractEntity;
import com.ww.scm.entity.pub.Dictionary;

@Entity
@Table(name = "T_MAT_ACCOUNT")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
// 账目
public class Account extends AbstractEntity{


	// 单据
	private Bill bill;
	// 事务
	private Transaction transaction;
	// 事务明细
	private TransactionDetail transactionDetail;
	// 现存量
	private Storage storage;
	// 单据日期
	private String billDate;
	// 物料
	private Dictionary materiel;
	// 数量
	private Double amount=0.0;
	// 重量
	private Double weight=0.0;
	// 源位置
	private Dictionary originEntity;
	// 目目标位置
	private Dictionary targetEntity;

	public Account() {
	}
	
	@Column(name = "F_BILL_DATE", nullable = false, length = 8)
	public String getBillDate() {
		return billDate;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_BILL_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Bill getBill() {
		return bill;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_TRANSACTION_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Transaction getTransaction() {
		return transaction;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_TRANSACTIONDETAIL_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public TransactionDetail getTransactionDetail() {
		return transactionDetail;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_STORAGE_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Storage getStorage() {
		return storage;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_MATERIEL_ID")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getMateriel() {
		return materiel;
	}

	@Column(name = "F_AMOUNT", nullable = false, precision = 12, scale = 4)
	public Double getAmount() {
		return amount;
	}

	@Column(name = "F_WEIGHT", nullable = false, precision = 12, scale = 4)
	public Double getWeight() {
		return weight;
	}
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_ORIGIN_ENTITY_ID") 
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getOriginEntity() {
		return originEntity;
	}
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
	@JoinColumn(name = "F_TARGET_ENTITY_ID") 
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public Dictionary getTargetEntity() {
		return targetEntity;
	}

	public void setBill(Bill bill) {
		this.bill = bill;
	}

	public void setTransaction(Transaction transaction) {
		this.transaction = transaction;
	}

	public void setTransactionDetail(TransactionDetail transactionDetail) {
		this.transactionDetail = transactionDetail;
	}

	public void setStorage(Storage storage) {
		this.storage = storage;
	}

	
	public void setBillDate(String billDate) {
		this.billDate = billDate;
	}

	public void setMateriel(Dictionary materiel) {
		this.materiel = materiel;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	public void setOriginEntity(Dictionary originEntity) {
		this.originEntity = originEntity;
	}

	public void setTargetEntity(Dictionary targetEntity) {
		this.targetEntity = targetEntity;
	}
	
	



	
}
